package main

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

const dsn = "gva:gvagva@tcp(172.1.4.155:3306)/gormtest?charset=utf8mb4&parseTime=True&loc=Local"

type UserJnn struct {
	gorm.Model
	Name string
	Age  int8
}

func main() {
	fmt.Println("Gorm 数据库操作")
	// 连接数据库
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {

		panic("连接数据库失败")

	}
	db.AutoMigrate(&UserJnn{})

}
